package com.imusic.common.exception;

import com.imusic.model.common.dtos.ResponseResult;
import com.imusic.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Log4j2
@RestControllerAdvice
public class ExceptionCatch {

    @ExceptionHandler(Exception.class)
    public ResponseResult exception(Exception e) {
        e.printStackTrace();
        //记录日志
        log.error("catch exception:{}", e.getMessage());
        //返回通用异常信息
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }


}
